package com.itlaobing.demo.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Classname LogoutServlet
 * @Description TODO()
 * @Date 2020/11/10 0010 16:54
 * @Author by Administrator
 * @Version v1.0
 */
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        // 清除用户信息
        session.removeAttribute("user");
        // 重定向到 登录
        resp.sendRedirect("login.jsp");

    }
}
